\hypertarget{codec_8h}{
\section{codec.h File Reference}
\label{codec_8h}\index{codec.h@{codec.h}}
}


Codec module header.  


{\ttfamily \#include $<$stdlib.h$>$}\par
{\ttfamily \#include $<$stdbool.h$>$}\par
{\ttfamily \#include \char`\"{}unix\_\-codec.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}windows\_\-codec.h\char`\"{}}\par
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structcodec}{codec}
\begin{DoxyCompactList}\small\item\em A codec definition that includes the codec name and its encoder and decoder function pointers. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{codec_8h_a413856ff351a845db6a953b1c55b0483}{
bool {\bfseries hasNext} (char $\ast$, int, char)}
\label{codec_8h_a413856ff351a845db6a953b1c55b0483}

\item 
\hypertarget{codec_8h_a5c38bab2e0cabf68d293321ef36040f2}{
char {\bfseries next} (const char $\ast$, int $\ast$, char $\ast$)}
\label{codec_8h_a5c38bab2e0cabf68d293321ef36040f2}

\item 
char $\ast$ \hyperlink{codec_8h_a50dc3fdba7738703a939b6a430dec05d}{nonatohex} (char c)
\begin{DoxyCompactList}\small\item\em Lookup the hex value of any character that is not alphanumeric. \item\end{DoxyCompactList}\item 
void \hyperlink{codec_8h_ac7c8ed1fae334b2bdeb310f599b3addc}{codec\_\-init} ()
\begin{DoxyCompactList}\small\item\em Initialize an array to mark which characters are to be encoded. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\hypertarget{codec_8h_a837996a59eb0319c13fbcd5267bca89a}{
\hyperlink{structcodec}{codec} $\ast$ \hyperlink{codec_8h_a837996a59eb0319c13fbcd5267bca89a}{pcodec\_\-unix}}
\label{codec_8h_a837996a59eb0319c13fbcd5267bca89a}

\begin{DoxyCompactList}\small\item\em A pointer to the global UNIX command shell codec definition. \item\end{DoxyCompactList}\item 
\hypertarget{codec_8h_af59eba6fa0bf7b3ad60c0cb87eb4a034}{
\hyperlink{structcodec}{codec} $\ast$ \hyperlink{codec_8h_af59eba6fa0bf7b3ad60c0cb87eb4a034}{pcodec\_\-windows}}
\label{codec_8h_af59eba6fa0bf7b3ad60c0cb87eb4a034}

\begin{DoxyCompactList}\small\item\em A pointer to the global Windows command shell codec definition. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Codec module header. The Codec module defines a set of functions for encoding and decoding application level encoding schemes, such as OS Command Shell escape encoding and Database interpreter escape encoding. Codecs are used in output encoding and canonicalization. Individual encoding schemes are implemented in separate modules and are accessed though function pointers in the global codec definition variables. The design of these codecs allows for character-\/by-\/character decoding, which is necessary to detect double-\/encoding and the use of multiple encoding schemes, both of which are techniques used by attackers to bypass validation and bury encoded attacks in data.

\begin{DoxySince}{Since}
June 1, 2007 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\hyperlink{canonicalize_8c_a5f24e36f844d85ce38bb26fb71d0e7ba}{esapi\_\-canonicalize()} 
\end{DoxySeeAlso}


Definition in file \hyperlink{codec_8h_source}{codec.h}.



\subsection{Function Documentation}
\hypertarget{codec_8h_ac7c8ed1fae334b2bdeb310f599b3addc}{
\index{codec.h@{codec.h}!codec\_\-init@{codec\_\-init}}
\index{codec\_\-init@{codec\_\-init}!codec.h@{codec.h}}
\subsubsection[{codec\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}void codec\_\-init (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{codec_8h_ac7c8ed1fae334b2bdeb310f599b3addc}


Initialize an array to mark which characters are to be encoded. 

Store the hex string for that character to save time later. If the character shouldn't be encoded, then store null. 

Definition at line 136 of file codec.c.

\hypertarget{codec_8h_a50dc3fdba7738703a939b6a430dec05d}{
\index{codec.h@{codec.h}!nonatohex@{nonatohex}}
\index{nonatohex@{nonatohex}!codec.h@{codec.h}}
\subsubsection[{nonatohex}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ nonatohex (
\begin{DoxyParamCaption}
\item[{char}]{c}
\end{DoxyParamCaption}
)}}
\label{codec_8h_a50dc3fdba7738703a939b6a430dec05d}


Lookup the hex value of any character that is not alphanumeric. 


\begin{DoxyParams}{Parameters}
{\em c} & The character to lookup. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
, return null if alphanumeric or the character code in hex. 
\end{DoxyReturn}


Definition at line 127 of file codec.c.



Referenced by encode\_\-windows\_\-char().

